<template>
	<view class="container">
		<view v-for="(item, index) in list" class="infoList" @click="openPopup(item)" v-if="list.length>0">
			<view class="box">
				<view class="name">
					{{item.userName}}
				</view>
				<view class="time">
					{{item.createTime}}
				</view>
			</view>
		</view>
		<view v-if="list.length==0" style="height: 300rpx;">
			<nullVue></nullVue>
		</view>
		<!-- 新增-->
		<view class="addForm">
			<button @click="add">{{app.language.wytj}}</button>
		</view>
		<!-- 弹窗 -->
		<uni-popup ref="popup" type="bottom">
		  <view class="popup-content">
			  <!-- 既往病史 -->
			  <view class="box">
			  	<view class="boxL">{{ app.language.rcjk_jwbs }}:</view>
			  	<view class="boxz">{{datainfo.pastMedicalHistory}}</view>
			  </view>
			  <!-- 疾病名称 -->
			  <view class="box" v-if="datainfo.diseaseName">
			  	<view class="boxL">{{ app.language.rcjk_jbName }}:</view>
			  	<view class="boxz">{{datainfo.diseaseName}}</view>
			  </view>
			  <!-- 患病时间 -->
			  <view class="box" v-if="datainfo.illnessTime">
			  	<view class="boxL">{{ app.language.rcjk_hbTime }}:</view>
			  	<view class="boxz">{{datainfo.illnessTime}}</view>
			  </view>
			  <!-- 治疗情况 -->
			  <view class="box" v-if="datainfo.treatmentStatus">
			  	<view class="boxL">{{ app.language.rcjk_zlqk }}:</view>
			  	<view class="boxz">{{datainfo.treatmentStatus}}</view>
			  </view>
			  <!-- 是否完成年度体检 -->
			  <view class="box">
			  	<view class="boxL">{{ app.language.rcjk_isNdtj }}:</view>
			  	<view class="boxz">{{datainfo.completePhysicalExamination}}</view>
			  </view>
			  <!-- 体检时间 -->
			  <view class="box" v-if="datainfo.inspectionTime">
			  	<view class="boxL">{{ app.language.rcjk_tjTime }}:</view>
			  	<view class="boxz">{{datainfo.inspectionTime}}</view>
			  </view>
			  <!-- 体检机构 -->
			  <view class="box" v-if="datainfo.inspectionInstitution">
			  	<view class="boxL">{{ app.language.rcjk_tjJgName }}:</view>
			  	<view class="boxz">{{datainfo.inspectionInstitution}}</view>
			  </view>
			  <!-- 肺部 -->
			  <view class="box" v-if="datainfo.lungs">
			  	<view class="boxL">{{ app.language.rcjk_lungs }}:</view>
			  	<view class="boxz">{{datainfo.lungs}}</view>
			  </view>
			  <!-- 胃部 -->
			  <view class="box" v-if="datainfo.stomach">
			  	<view class="boxL">{{ app.language.rcjk_stomach }}:</view>
			  	<view class="boxz">{{datainfo.stomach}}</view>
			  </view>
			  <!-- 肝功能 -->
			  <view class="box" v-if="datainfo.liverFunction">
			  	<view class="boxL">{{ app.language.rcjk_liverFunction }}:</view>
			  	<view class="boxz">{{datainfo.liverFunction}}</view>
			  </view>
			  <!-- 高压 -->
			  <view class="box" v-if="datainfo.bloodPressure">
			  	<view class="boxL">{{ app.language.jbjk_bloodPressure }}:</view>
			  	<view class="boxR" v-if="datainfo.bloodPressurezt==app.language.hg">{{datainfo.bloodPressurezt}}</view>
			  	<view class="boxR1" v-if="datainfo.bloodPressurezt==app.language.bhg">{{datainfo.bloodPressurezt}}</view>
			  </view>
			  <!-- 低压 -->
			  <view class="box" v-if="datainfo.dycountzt">
			  	<view class="boxL">{{ app.language.jbjk_bloodPressured }}:</view>
			  	<view class="boxR" v-if="datainfo.dycountzt==app.language.hg">{{datainfo.dycountzt}}</view>
			  	<view class="boxR1" v-if="datainfo.dycountzt==app.language.bhg">{{datainfo.dycountzt}}</view>
			  </view>
			  <!-- 心电图 -->
			  <view class="box" v-if="datainfo.electrocardiogram">
			  	<view class="boxL">{{ app.language.rcjk_electrocardiogram }}:</view>
			  	<view class="boxz">{{datainfo.electrocardiogram}}</view>
			  </view>
			  <!-- 左视力 -->
			  <view class="box" v-if="datainfo.leftVisualAcuity">
			  	<view class="boxL">{{ app.language.rcjk_leftVisualAcuity }}:</view>
			  	<view class="boxz">{{datainfo.leftVisualAcuity}}</view>
			  </view>
			  <!-- 右视力 -->
			  <view class="box" v-if="datainfo.rightVisualAcuity">
			  	<view class="boxL">{{ app.language.rcjk_rightVisualAcuity }}:</view>
			  	<view class="boxz">{{datainfo.rightVisualAcuity}}</view>
			  </view>
			  <!-- 尿常规 -->
			  <view class="box" v-if="datainfo.urinalysis">
			  	<view class="boxL">{{ app.language.rcjk_urinalysis }}:</view>
			  	<view class="boxz">{{datainfo.urinalysis}}</view>
			  </view>
			  <!-- 血常规 -->
			  <view class="box">
			  	<view class="boxL" v-if="datainfo.bloodRoutine">{{ app.language.rcjk_bloodRoutine }}:</view>
			  	<view class="boxz">{{datainfo.bloodRoutine}}</view>
			  </view>
			  <!-- 健康情况 -->
			  <view class="box" v-if="datainfo.healthCondition">
			  	<view class="boxL">{{ app.language.rcjk_healthCondition }}</view>
			  	<view class="boxz">{{datainfo.healthCondition}}</view>
			  </view>
		  </view>
		</uni-popup>
	</view>
</template>

<script>
	import { getJbjk } from '@/api/user.js'
	import nullVue from '@/components/null';
	const global = getApp().globalData;
	export default {
		components:{
			nullVue
		},
		data() {
			return {
				app: {
					global :global,
					name: global.appName,
					language: global.language 
				},
				list:[],
				token:"",
				hrUuid:"",
				userInfo:{},
				isNdtj:false,
				isJwbs:false,
				datainfo:{}
			}
		},
		onLoad() {
			this.getToken()
			setTimeout(() => {
			    this.getList()
			}, 1000);
		},
		methods: {
			// 获取token
			getToken(){
				let that = this
				uni.getStorage({
				    key: 'loginData',
				    success: function (res) {
						that.token = res.data.userInfo.appToken
						that.hrUuid = res.data.userInfo.uuid
						that.userInfo = res.data.userInfo
				    }
				});
			},
			
			// 获取日常健康情况列表
			getList(){
				uni.showLoading({
					title: this.app.language.jzz,
				});
				let data = {
					hrUuid:this.hrUuid,
					token:this.token
				}
				console.log('data',data)
				getJbjk(data).then((res) => {
					uni.hideLoading();
					this.list = res.rows
					for (let i = 0; i < this.list.length; i++) {
						this.list[i].userName = this.userInfo.userName
						// 血压
						if (this.list[i].bloodPressure >= '90' && this.list[i].bloodPressure <= '140') {
							this.list[i].bloodPressurezt = this.app.language.hg
						} else {
							this.list[i].bloodPressurezt = this.app.language.bhg
						}
						// 低压
						if (this.list[i].dycount >= '60' && this.list[i].dycount <= '90') {
							this.list[i].dycountzt = this.app.language.hg
						} else {
							this.list[i].dycountzt = this.app.language.bhg
						}
					}
				  })
			},
			
			openPopup(item) {
				this.datainfo = item
				this.$refs.popup.open()
			},
			closePopup() {
			    this.$refs.popup.close()
			},
			
			// 新增民警日常健康
			add(){
				uni.navigateTo({
					url: '../user/jbHealthAdd'
				});
			}
		}
	}
</script>

<style>
	.container{
		padding: 0 10rpx;
	}
	.infoList {
		/* border-bottom: 1px dashed #ddd; */
		padding: 15rpx;
		font-size: 26rpx;
		box-shadow: 1px 1px 10rpx #ddd;
		margin-bottom: 15rpx;
	}
	
	.time{
		margin-left: auto;
	}
	
	.qua{
		color: blue;
		font-weight: 500;
		text-align: right;
		margin-top: 10rpx;
	}
	
	.NoQua{
		color: red;
		font-weight: 500;
		text-align: right;
		margin-top: 10rpx;
	}
	
	.addForm button{
		background-color: #2f8ef9;
		color: #fff;
		font-size: 28rpx;
		height: 60rpx;
		line-height: 60rpx;
		/* position: fixed;
		bottom: 0; */
		margin-top: 30rpx;
		width: 97%;
	}
	
	.box{
		border-bottom: 1px dashed #ddd;
		display: flex;
		padding: 15rpx 0;
	}
	
	.boxR{
		margin-left: auto;
		padding: 5rpx 31rpx;
		font-size: 22rpx;
		border-radius: 5rpx;
		border: 1px solid #59bea0;
		color: #59bea0;
		/* border-bottom: 1px solid #ddd; */
		padding: 5rpx 16rpx;
		width: 157rpx;
		text-align: center;
	}
	
	.boxR1{
		margin-left: auto;
		padding: 5rpx 31rpx;
		font-size: 22rpx;
		border-radius: 5rpx;
		border: 1px solid #d6605c;
		color: #d6605c;
		/* border-bottom: 1px solid #ddd; */
		padding: 5rpx 16rpx;
		width: 157rpx;
		text-align: center;
	}
	.boxz{
		margin-left: auto;
		padding: 5rpx 31rpx;
		font-size: 22rpx;
		border-radius: 5rpx;
		border: 1px solid #414040;
		color: #414040;
		/* border-bottom: 1px solid #ddd; */
		padding: 5rpx 16rpx;
		text-align: center;
		width: 157rpx;
	}
	
	.popup-content{
		background-color: #fff;
		padding: 20rpx;
	}
	
	.vue-ref {
		padding-bottom: 0 !important;
	}
</style>